package cn.jltx.mvpdemopro;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * @author jltxseo
 *         Created by junlintianxia on 2016/04/11.
 */

public class UserActivity extends AppCompatActivity implements View.OnClickListener{
    private TextView tvUser;
    private TextView tvPassword;
    private Button btnLoginOut;

    private void assignViews() {
        tvUser = (TextView) findViewById(R.id.tv_user);
        tvPassword = (TextView) findViewById(R.id.tv_password);
        btnLoginOut = (Button)findViewById(R.id.btn_login_out);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user_main);
        Bundle localBudle = getIntent().getExtras();
        String userName = localBudle.getString("user");
        String userPw = localBudle.getString("password");
        assignViews();
        tvUser.setText(userName);
        tvPassword.setText(userPw);
        btnLoginOut.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_login_out:
                Intent intent = new Intent(this,MainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                break;
            default:
                break;
        }
    }
}
